import { defineStore } from "pinia";

export type TreeMsgFunc = ()=>void
export const useTreeMsgStore = defineStore('treeMsg', ()=>{
    const callbacks:Record<number, TreeMsgFunc|undefined> = {}
    function addCallback(id:number, callback:TreeMsgFunc){
        callbacks[id] = callback
    }
    function call(id:number){
        const callback = callbacks[id]
        if(callback){
            callback()
        }
    }
    return{
        addCallback,
        call
    }
})